<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 添加、修改
    localStorage.setItem("username","张三")
    localStorage.setItem("age",21)
    localStorage.setItem("ispass",true)
    localStorage.setItem("person",{uname:"王五",age:22})
    // 对象类型：先转成字符串，读取的时候在转成对象
    var obj = {unam:"王五",age:22}
    var str = JSON.stringify(obj)
    localStorage.getItem("person",str)
    var username=localStorage.getItem("username")
    var str = JSON.localStorage.getItem("age")
    var ispass = localStorage.getItem("ispass")
    // 读取
    var person = localStorage.getItem("parson")
    // console.log(parson);
    person = JSON.parse(person)
    // console.log(person);
    console.log(person,uname);
    // 删除
    localStorage.removeItem("age")
</script>
</html>